<?php
/*
	$acomp = GetActiveCompany ();

	$imgm = imagecreatefromjpeg(MAPSPATH.$acomp[id].".jpg");

    $imgheight = imagesy($imgm);
    $imgwidth = imagesx($imgm);
	////////////////////////////////////////////////////////////////////////////
	//  RED FORCES
	////////////////////////////////////////////////////////////////////////////
    $imgf = imagecreatefromgif(ALLIMGPATH."a_f.gif");

    $all_fields = GetAllArmyFields(1);

    if(is_array($all_fields) and count($all_fields)>0)
    foreach($all_fields as $field) {

        $cx = $field[positionx] * ($imgwidth / $acomp[maxx]);
        $cy = $field[positiony] * ($imgwidth / $acomp[maxy]);

    	$cx = round($cx,0);
        $cy = $imgheight - round($cy,0);

		imagecopy($imgm,$imgf,$cx,$cy,0,0,30,30);

        $finfo = GetBaseStatus ($field[id]);

        $finfo[squads] = @implode(",",$finfo[squads]);

        $finfo = "fuel: ".$finfo[field][fuel]."\r\nammo: ".$finfo[field][ammo]."\r\nrepair: ".$finfo[field][repair]."\r\nsquads: ".$finfo[squads];

        $TPmain->AssignTagPlus("<!--mapareas-->","\r\n<area shape=\"rect\" coords=\"$cx,$cy,".($cx+30).",".($cy+30)."\" alt=\"".$finfo."\" \r\nhref=\"<!--SiteURL-->fields/".$field[id]."/index.html\">");
    }


	////////////////////////////////////////////////////////////////////////////
	//  BLUE FORCES
	////////////////////////////////////////////////////////////////////////////
    $imgf = imagecreatefromgif(ALLIMGPATH."b_f.gif");

    $all_fields = GetAllArmyFields(2);

    if(is_array($all_fields) and count($all_fields)>0)
    foreach($all_fields as $field) {

    	$imgheight = imagesy($imgm);

        $cx = $field[positionx] * ($imgwidth / $acomp[maxx]);
        $cy = $field[positiony] * ($imgwidth / $acomp[maxy]);

    	$cx = round($cx,0);
        $cy = $imgheight - round($cy,0);

    	//echo "hehe: cx:$cx, cy:$cy\r\n";

		imagecopy($imgm,$imgf,$cx,$cy,0,0,30,30);

        $finfo = GetBaseStatus ($field[id]);

        $finfo[squads] = @implode(",",$finfo[squads]);

        $finfo = "fuel: ".$finfo[field][fuel]."\r\nammo: ".$finfo[field][ammo]."\r\nrepair: ".$finfo[field][repair]."\r\nsquads: ".$finfo[squads];

        $TPmain->AssignTagPlus("<!--mapareas-->","\r\n<area shape=\"rect\" coords=\"$cx,$cy,".($cx+30).",".($cy+30)."\" alt=\"".$finfo."\" \r\nhref=\"<!--SiteURL-->fields/".$field[id]."/index.html\">");
    }

    imagejpeg($imgm,ALLIMGPATH."temp.jpg",100);
  */

  $map = GetMissionImage();

  if ($map) {
	  copy(ALLIMGPATH."temp.jpg", ALLIMGPATH."temp_old.jpg");
	  $mapfile = fopen(ALLIMGPATH."temp.jpg","w");
	  fwrite($mapfile,$map);
	  fclose($mapfile);

      mysql_query("update mission set mapa=''");
  }

?>